export function formatTimestamp(timestamp: number) {
	return {
		day: Math.floor(timestamp / 1000 / 60 / 60 / 24),
		hour: Math.floor((timestamp / 1000 / 60 / 60) % 24),
		minutes: Math.floor((timestamp / 1000 / 60) % 60),
		seconds: Math.floor((timestamp / 1000) % 60),
	};
}

export function getTime(durationInMillis) {
	const time = formatTimestamp(durationInMillis);
	let timeString = '';
	if (time.day > 0) {
		timeString = time.day + '天' + time.hour + '小时' + time.minutes + '分钟' + time.seconds + '秒';
	} else if (time.hour > 0) {
		timeString = time.hour + '小时' + time.minutes + '分钟' + time.seconds + '秒';
	} else if (time.minutes > 0) {
		timeString = time.minutes + '分钟' + time.seconds + '秒';
	} else {
		timeString = time.seconds + '秒';
	}
	return timeString;
}
